package com.bloom.opensourceframework.echart;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
//import android.webkit.WebSettings;
//import android.webkit.WebView;

import com.bloom.opensourceframework.R;
import com.bloom.opensourceframework.activity.BaseActivity;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;

/**
 * Created by bloom on 2018/5/24.
 */

public class EChartExampleActivity extends BaseActivity {

    private WebView mWebView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_echarts);
        setTitle("EChart");
        initView();
    }

    private void initView() {
        mWebView = (WebView) findViewById(R.id.webview);

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setSupportZoom(true);
        webSettings.setDisplayZoomControls(true);

//        mWebView.loadUrl("file:///android_asset/report/Chart.html");
        mWebView.loadUrl("http://echarts.baidu.com/examples/editor.html?c=line-draggable");

        findViewById(R.id.bt_load).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String json = "{widgettype:'bar'}";
                String func = "javascript:loadChart(" + json + ")";
                mWebView.loadUrl(func);
            }
        });
    }

}
